package com.mumulx.check.web.config.security.auth;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.web.session.SessionInformationExpiredEvent;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;
import org.springframework.stereotype.Component;
 import javax.servlet.ServletException;
import java.io.IOException;
/*
 *
 * @author mumulx
 * @creed: mumulx编写
 * @email: 2606964863@qq.com
 * @date 2020/10/27 20:40
 * @param null
 * @return
 * 限制最大用户登录数量
 */
@Component
@Slf4j
public class MyExpiredSessionStrategy implements SessionInformationExpiredStrategy {


    //session超时后会调用
    @Override
    public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
        //跳转到其他页面
        event.getRequest().getRequestDispatcher("/help/error503").forward(event.getRequest(), event.getResponse());

    }
}
